/**
 * components/Row.js
 * Define your component using platform-independent primitives
 */
import React from "react";

import { StyleSheet, Text, View } from "react-native";

import PropTypes from "prop-types";

import { Color, FontSize, scale } from "../../common/index";

const Tag = props => {
  const {
    text, selected, onPress, defaultStyle, selecteStyle,
  } = props;
  const borderStyle = selected ? selecteStyle : defaultStyle;
  return (
    <View style={[styles.conatiner, borderStyle]}>
      <Text name={text} style={styles.text} onPress={onPress}>
        {text}
      </Text>
    </View>
  );
};

Tag.propTypes = {
  onPress: PropTypes.func,
  text: PropTypes.string.isRequired,
  defaultStyle: PropTypes.any,
  selecteStyle: PropTypes.any,
  selected: PropTypes.bool,
};

Tag.defaultProps = {
  selected: false,
  onPress: () => {},
  defaultStyle: {
    backgroundColor: Color.bg_unselected,
    borderColor: Color.text_assist,
  },
  selecteStyle: {
    backgroundColor: Color.bg_selected,
    borderColor: Color.bg_selected,
  },
};

const styles = StyleSheet.create({
  conatiner: {
    borderRadius: scale * 5,
    marginHorizontal: scale * 8,
    marginVertical: scale * 8,
    borderWidth: StyleSheet.hairlineWidth,
  },
  text: {
    paddingVertical: scale * 6,
    paddingHorizontal: scale * 12,
    color: Color.text_content,
    fontSize: FontSize.SIZE_14,
  },
});
export default Tag;
